import { FC, useEffect, useState } from 'react';
import { useNavigate } from 'react-router';
import { getBuildingList } from '../services/building/building'
import { Tree,Button} from 'antd';
import '../assets/css/tree.less'
const Index: FC<any> = (props: any): JSX.Element => {

    const [treeData, setTreeData] = useState<any>([])

    const getTreeData = async () => {

        const res: any = await getBuildingList({});
        console.log(res);
        if (res.errCode === 10000) {
            setTreeData(res.data.list);
        }


    }

    useEffect(() => {
        getTreeData();


    }, [])

    const titleRender=(data:any)=>{

        return (
            <div className='treetitle'>
              <span>{data.name}</span>
               <div> <Button type="primary">添加子节点</Button>
              <Button type="primary">修改</Button>
              <Button type="primary" danger>删除</Button></div>
            </div>
        )

    }

    return (
        <div>tree

            <Tree
                titleRender={titleRender}
                treeData={treeData}
            />
        </div>
    )
}
export default Index;